<?php
/**
 * 微信菜单管理
 * 跃飞科技版权所有 @2017
 * User: 钟贵廷
 * Date: 2017/5/17
 * Time: 10:11
 */

namespace app\admin\controller;

class Menu extends Admin
{

    public function lst()
    {
        $menuModel  = model('Menu');
        $data['menu_data'] =  $menuModel->select()->toArray();
        return $this->fetch('',$data);
    }

    public function add()
    {
        $access_token = $this->get_access_token();
        $url = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token={$access_token}";
        $menuModel  = model('Menu');
        $menuData = $menuModel->add();
        $jsonMenuData = $this->cn_json_encode($menuData);
        p($jsonMenuData);
        $res =$this->https_request($url,$jsonMenuData);
        p($res);
    }

    public function delete()
    {
        $access_token = $this->get_access_token();
        $url = "https://api.weixin.qq.com/cgi-bin/menu/delete?access_token={$access_token}";
        $res = $this->https_request($url);
        p($res);
    }



}
